﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RegisterService;
using CoreData;
using System.Threading;
namespace ImportExport
{
    public partial class frmUpdateStudent : Form
    {
        public frmUpdateStudent()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
        }
        Thread tsupdate;
        private void button1_Click(object sender, EventArgs e)
        {
            tsupdate = new Thread(new ThreadStart(() => Update()));
            tsupdate.Start();
        }
        void Update()
        {
            var data = RegisterService.RegisterServices.StudentService.GetList() as List<Student>;
           // int i=0;
           for(int i=0;i<data.Count;i++)
            {
                lblinfo.Text = "";
                string mess="";
              var id = RegisterService.RegisterServices.StudentService.Save(data[i],ref mess);

                lblinfo.Text = " Process: " + data[i].Code;

               //  i++;
                 if (id <= 0)
                 {
                     lblinfo.Text = " Process failed: " + data[i].Code;
                     break;
                 }
            }
        }
    }
}
